/*
 * lib2Desa - Another 2D game library in C++
 * Copyright (C) 2009 Erivaldo Xavier de Lima Filho
 *
 * This program is free software and is distributed under GNU General Public License version 3. You can modify and/or redistribute
 * it under the terms of GPL version 3 or posterior version. This program comes with NO WARRANTY, for more details, see LICENSE,
 * or <http://www.gnu.org/licenses>.
 *
 * Contact info:
 *
 *	Erivaldo Xavier de Lima Filho, desadoc@gmail.com
 *
 */

#ifndef _GAMEOBJECT_HPP
#define _GAMEOBJECT_HPP

#include "Core/shared_ptr.hpp"
#include "Core/GameElement.hpp"
#include "Core/IEventListener.hpp"
#include "Core/IGraphicDevice.hpp"
#include "Core/Animation.hpp"
#include "Core/Rect.hpp"

#include <vector>
#include <list>

#ifndef _NO_NAMESPACE
namespace lib2Desa {
#endif

class GameObject : public GameElement, public IEventListener
{

protected:

	std::vector<shared_ptr<Animation> > animations;
	std::list<u16> enabled;
	vector2f dim;

public:

	GameObject(const shared_ptr<GameObject>& parent = null, const vector2f& pos = vector2f()) : GameElement(parent, pos)
	{
		// TODO
		u32 i = 0;
		for(; i< animations.size(); i++)
		{
			animations[i] = null;
		}
	}

	virtual ~GameObject(void);

	virtual void draw(const shared_ptr<IGraphicDevice>& gs) const;
	virtual bool run(u32 ml);

	virtual void setAnimation(u16 index, const shared_ptr<Animation>& ani);
	virtual shared_ptr<Animation> getAnimation(u16 index) const;
	virtual void enableAnimation(u16 index, bool enable);

	virtual void notify(shared_ptr<IEvent> e);

	void setDimension(const vector2f& d)
	{
		dim = d;
	}

	const Rect getRect(void) const
	{
		return Rect(getAbsPos(), dim);
	}
};

#ifndef _NO_NAMESPACE
}
#endif

#endif /*GameObject.hpp included*/
